#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
    int maxArea(vector<int>& height)
    {
        int left = 0, right = height.size() - 1;
        int ret = 0;
        while (left < right)
        {
            int capacity = (right - left) * min(height[left], height[right]);
            if (capacity > ret)
            {
                ret = capacity;
            }
            if (height[left] < height[right])
            {
                ++left;
            }
            else
            {
                --right;
            }
        }
        return ret;
    }
};